from basic import *


class Command:
    def __init__(self, name: str):
        self.instruction = name
        self.name, self.values = None, []
        self.c_value = 0
        self.t_reg, self.s_reg1, self.s_reg2 = 0, 0, 0
        self.imm1, self.imm2, self.imm3 = 0, 0, 0

    def decode(self):
        self.name, self.values = self.instruction.split(
            ' ')[0], self.instruction.split(' ')[1].split(',')
        self.c_value = command_list[self.name]


class Data:
    def __init__(self, name: str):
        self.instruction = name
        self.name, self.type, self.value = None, None, None

    def decode(self):
        self.name = self.instruction.split('')[0]
        self.type, self.value = self.instruction.split(' ')[1].split(',')
        self.type = labels_list[self.type]


class Segment:
    def __init__(self, name: str):
        self.descript = name
        self.pType, self.pLength, self.pEntry = 0, 0, 0
        self.pName = None

    def dispatch(self):
        self.pName = self.descript.split(' ')[-1][:-1]
        self.pType = labels_list[self.descript.split(' ')[1]]
        if self.pName.find(',') != -1:
            self.pName, self.pEntry = self.pName.split(
                ',')[0], self.pName.split(',')[1]
